.TH std::operator<<(std::basic_stacktrace) 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::operator<<(std::basic_stacktrace) \- std::operator<<(std::basic_stacktrace)

.SH Synopsis
   Defined in header <stacktrace>
   template< class Allocator >
   std::ostream& operator<<( std::ostream& os, const                      (since C++23)
   std::basic_stacktrace<Allocator>& st );

   Inserts the description of st into the output stream os. Equivalent to return os <<
   std::to_string(st);.

.SH Parameters

   os - an output stream
   st - a basic_stacktrace whose description is to be inserted

.SH Return value

   os.

.SH Exceptions

   May throw implementation-defined exceptions.

.SH Example


// Run this code

 #include <stacktrace>
 #include <iostream>

 int main()
 {
     std::cout << "The stacktrace obtained in the main function:\\n";
     std::cout << std::stacktrace::current() << '\\n';
     []{
         std::cout << "The stacktrace obtained in a nested lambda:\\n";
         std::cout << std::stacktrace::current() << '\\n';
     }();
 }

.SH Possible output:

 The stacktrace obtained in the main function:
  0# 0x0000000000402E7B in ./prog.exe
  1# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
  2# 0x0000000000402CD9 in ./prog.exe

 The stacktrace obtained in a nested lambda:
  0# 0x0000000000402DDA in ./prog.exe
  1# 0x0000000000402EB2 in ./prog.exe
  2# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
  3# 0x0000000000402CD9 in ./prog.exe

.SH See also

   operator<< performs stream output of stacktrace_entry
   (C++23)    \fI(function template)\fP
